package com.bbseguros.pesquisador.middle;

import java.util.List;

import com.bbseguros.pesquisador.bean.DataBean;
import com.bbseguros.pesquisador.bean.UserBean;
import com.bbseguros.pesquisador.dao.UserDAO;


/**
 * @author hmsilva
 *
 */
public class UserMiddle {
	
	/**
	 * @param bean
	 * @return
	 */
	public static boolean insertUser(UserBean bean){
		UserDAO dao = UserDAO.getInstance();
		return dao.insertUser(bean);
	}


	/**
	 * @param id
	 * @return
	 */
	public static boolean deleteUser(int id){		
		UserDAO dao = UserDAO.getInstance();
		return dao.deleteUser(id);		
	}
	
	/**
	 * @param id
	 * @return
	 */
	public static UserBean selectUserByID(String id){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectUserByID(id);
	}
	
	/**
	 * @param id
	 * @return
	 */
	public static UserBean selectUserByCodUser(String codUser){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectUserByUserCode(codUser);
	}	

	/**
	 * @return
	 */
	public static List<UserBean> getListUsers(){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectAllUser();
	}
	
	/**
	 * @return
	 */
	public static List<UserBean> getListUsers(int groupId){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectAllUser(groupId);
	}	
	
	/**
	 * @return
	 */
	public static List<DataBean> getListGrupo(){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectAllGrupo();
	}
	
	/**
	 * @return
	 */
	public static List<DataBean> getListPerfil(){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectAllPerfil();
	}
	
	/**
	 * @return
	 */
	public static DataBean getPerfilByID(String id){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectPerfilByID(id);
	}
	
	/**
	 * @return
	 */
	public static DataBean getGrupoByID(String id){
		UserDAO dao = UserDAO.getInstance();
		return dao.selectGrupoByID(id);
	}
	
	/**
	 * @return
	 */
	public static boolean changeStatus(String id, String status){
		UserDAO dao = UserDAO.getInstance();
		return dao.updateStatus(id, status);
	}
	
	/**
	 * @return
	 */
	public static boolean updateUser(UserBean user){
		UserDAO dao = UserDAO.getInstance();
		return dao.updateUser(user);
	}
	
	/**
	 * @param userName
	 * @return
	 */
	public static boolean verifyUser(String userName){
		UserDAO dao = UserDAO.getInstance();
		if (dao.selectUser(userName) != null ) {
			return true;
		}
		return false;	
	}
	
	/**
	 * @param codUser
	 * @return
	 */
	public static boolean verifyCodUser(String codUser){
		UserDAO dao = UserDAO.getInstance();
		if (dao.selectUserByUserCode(codUser)!= null ) {
			return true;
		}
		return false;	
	}
	
}
